$(function(){
  imgSize($(".topic-img-box"));
})
function imgSize (obj) {
  obj.each(function(){
    var imgWidth = $(this).width();
    $(this).next().height(imgWidth);
    $(this).height(imgWidth);
    var img=$(this).children();
    var imgItem=new Image();
    imgItem.src=img.attr("src");
    var imgRealWidth=imgItem.width;
    var imgRealHeight=imgItem.height;
    if(imgRealWidth==imgRealHeight){
      img.css("width","100%");
      img.css("height","100%");
    }else if(imgRealWidth>imgRealHeight){
      img.css("height","100%");
    }else if(imgRealWidth<imgRealHeight){
      img.css("width","100%");
    }
  });
};